﻿CREATE PROCEDURE [maint].[GetCurrentBackupSetDetails]
@GroupName [sysname], @Name [sysname] OUTPUT, @ExpirationDate DATETIME OUTPUT
AS
BEGIN
	SELECT TOP 1
		@Name = [name]
		,@ExpirationDate = [expiration_date]
	FROM [msdb].dbo.backupset
	WHERE  (LEFT([name],LEN(@GroupName)) = @GroupName)
		AND([type] = N'D')
		AND([expiration_date] > CURRENT_TIMESTAMP)
	ORDER BY
		[database_backup_lsn] DESC

	RETURN(0)
END